#include "array.h"
#include <stdio.h>

doubleArray *createDoubleArray(long int size) {
	doubleArray *dArray;
	if (size < 0) {
		size = 0;
	}
	dArray = (doubleArray*)malloc(sizeof(doubleArray));
	dArray->array = (double*)malloc(size * sizeof(double));
	dArray->size = size;

	return dArray;
}

long int getWidthDoubleArray(doubleArray *dArray) {
	return dArray->size;
}

double2DArray *createDouble2DArray(long int width, long int height) {
	int i;
	double2DArray *d2DArray;
	if (width < 0) {
		width = 0;
	}
	if (height < 0) {
		height = 0;
	}
	d2DArray = (double2DArray*)malloc(sizeof(double2DArray));
	d2DArray->matrix = (doubleArray**)malloc(height * sizeof(doubleArray*));
	d2DArray->size = height;
	for (i = 0; i < height; i++) {
		d2DArray->matrix[i] = createDoubleArray(width);
	}

	return d2DArray;
}

long int getWidthDouble2DArray(double2DArray *d2DArray) {
	return d2DArray->matrix[0]->size;
}

long int getHeightDouble2DArray(double2DArray *d2DArray) {
	return d2DArray->size;
}

void setValueDouble2DArray(double2DArray *d2DArray, long int col, long int line, double value) {
	d2DArray->matrix[line]->array[col] = value;
}
